#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;
const int mat[3][3] = {{ 0, 1, 1 } , { 1, 0, 2 }, { 1, 2, 0 }};

char a[N], b[N];
int n, f[N][3];

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in; scanf("%s", a + 1); scanf("%s", b + 1); ++n; a[n] = b[n] = '0';
	rep(i, 1, n) a[i] -= '0', b[i] -= '0';
	memset(f, 0x3f, sizeof f);
	f[1][0] = a[1] ^ b[1]; f[1][1] = (0 ^ b[1]) + 1; f[1][2] = (1 ^ b[1]) + 1;
	rep(i, 1, n - 1)
		rep(j, 0, 2)
		rep(k, 0, 2) {
		int lst = j == 0 ? a[i] : j - 1, cur = k == 0 ? a[i + 1] : k - 1;
		lst ^= b[i]; cur ^= b[i + 1];
		chkmin(f[i + 1][k], f[i][j] + (lst ^ cur) + mat[j][k]);
	} printf("%d\n", f[n][0] >> 1);
	return 0;
}
